# Table B2

#####
rm(list=ls(all=TRUE))

library(MASS)
library(stargazer)

#### Dataset Original ####
setwd("/Users/sebastian/Dropbox/The politics of interruptions - JOP RR/Replication Files/Data Rep")
load("data_empirics_count_rep.Rdata")
load("data_empirics_length_rep.Rdata")

#### Datasets Threshold ----
load("data_empirics_count_0.Rdata") 
load("data_empirics_count_50.Rdata") 
load("data_empirics_count_100.Rdata") 
load("data_empirics_count_200.Rdata") 
load("data_empirics_length_0.Rdata") 
load("data_empirics_length_50.Rdata") 
load("data_empirics_length_100.Rdata") 
load("data_empirics_length_200.Rdata") 

#### TABLE B2: Thresholds -----
data_empirics_count_0$female_dum <- factor(data_empirics_count_0$female_dum, labels = c("Men", "Women"))
data_empirics_count$female_dum <- factor(data_empirics_count$female_dum, labels = c("Men", "Women"))
data_empirics_count_50$female_dum <- factor(data_empirics_count_50$female_dum, labels = c("Men", "Women"))
data_empirics_count_100$female_dum <- factor(data_empirics_count_100$female_dum, labels = c("Men", "Women"))
data_empirics_count_200$female_dum <- factor(data_empirics_count_200$female_dum, labels = c("Men", "Women"))

## No threshold:
model_0.1.1b <- glm.nb(tot_speeches_leg_cohort ~ female_dum + factor(cohort), 
                       data = data_empirics_count_0)

model_0.1.2b <- glm.nb(tot_speeches_leg_cohort ~ female_dum + ideology_ext + 
                         committee_chair + seniority + type_member + party_match_pres + 
                         post_2008 + negative_lang_mean  +
                         factor(cohort),
                       data = data_empirics_count_0)

model_0.1.3 <- glm.nb(length_speech_combined_session ~ female_dum +
                        factor(cohort), 
                      data = data_empirics_length_0)

model_0.1.4 <- glm.nb(length_speech_combined_session ~ female_dum + ideology_ext + 
                        committee_chair + seniority + type_member + party_match_pres + 
                        post_2008 + election_year + negative_lang_leg_session +
                        dum_mujeres_session +
                        factor(cohort), 
                      data = data_empirics_length_0)

# Original 
model_20.1.1b <- glm.nb(tot_speeches_leg_cohort ~ female_dum + factor(cohort), 
                        data = data_empirics_count)

model_20.1.2b <- glm.nb(tot_speeches_leg_cohort ~ female_dum + ideology_ext + 
                          committee_chair + seniority + type_member + party_match_pres + 
                          post_2008 + negative_lang_mean  +
                          factor(cohort),
                        data = data_empirics_count)

model_20.1.3 <- glm.nb(length_speech_combined_session ~ female_dum +
                         factor(cohort), 
                       data = data_empirics_length)

model_20.1.4 <- glm.nb(length_speech_combined_session ~ female_dum + ideology_ext + 
                         committee_chair + seniority + type_member + party_match_pres + 
                         post_2008 + election_year + negative_lang_leg_session +
                         dum_mujeres_session +
                         factor(cohort), 
                       data = data_empirics_length)

# > 50 Threshold
model_50.1.1b <- glm.nb(tot_speeches_leg_cohort ~ female_dum + factor(cohort), 
                        data = data_empirics_count_50)

model_50.1.2b <- glm.nb(tot_speeches_leg_cohort ~ female_dum + ideology_ext + 
                          committee_chair + seniority + type_member + party_match_pres + 
                          post_2008 + negative_lang_mean  +
                          factor(cohort),
                        data = data_empirics_count_50)

model_50.1.3 <- glm.nb(length_speech_combined_session ~ female_dum +
                         factor(cohort), 
                       data = data_empirics_length_50)

model_50.1.4 <- glm.nb(length_speech_combined_session ~ female_dum + ideology_ext + 
                         committee_chair + seniority + type_member + party_match_pres + 
                         post_2008 + election_year + negative_lang_leg_session +
                         dum_mujeres_session +
                         factor(cohort), 
                       data = data_empirics_length_50)

# > 100 Threshold
model_100.1.1b <- glm.nb(tot_speeches_leg_cohort ~ female_dum + factor(cohort), 
                         data = data_empirics_count_100)

model_100.1.2b <- glm.nb(tot_speeches_leg_cohort ~ female_dum + ideology_ext + 
                           committee_chair + seniority + type_member + party_match_pres + 
                           post_2008 + negative_lang_mean  +
                           factor(cohort),
                         data = data_empirics_count_100)

model_100.1.3 <- glm.nb(length_speech_combined_session ~ female_dum +
                          factor(cohort), 
                        data = data_empirics_length_100)

model_100.1.4 <- glm.nb(length_speech_combined_session ~ female_dum + ideology_ext + 
                          committee_chair + seniority + type_member + party_match_pres + 
                          post_2008 + election_year + negative_lang_leg_session +
                          dum_mujeres_session +
                          factor(cohort), 
                        data = data_empirics_length_100)

# > 200 Threshold
model_200.1.1b <- glm.nb(tot_speeches_leg_cohort ~ female_dum + factor(cohort), 
                         data = data_empirics_count_200)

model_200.1.2b <- glm.nb(tot_speeches_leg_cohort ~ female_dum + ideology_ext + 
                           committee_chair + seniority + type_member + party_match_pres + 
                           post_2008 + negative_lang_mean  +
                           factor(cohort),
                         data = data_empirics_count_200)

model_200.1.3 <- glm.nb(length_speech_combined_session ~ female_dum +
                          factor(cohort), 
                        data = data_empirics_length_200)

model_200.1.4 <- glm.nb(length_speech_combined_session ~ female_dum + ideology_ext + 
                          committee_chair + seniority + type_member + party_match_pres + 
                          post_2008 + election_year + negative_lang_leg_session +
                          dum_mujeres_session +
                          factor(cohort), 
                        data = data_empirics_length_200)

## TABLE B2: Thresholds----

setwd("/Users/sebastian/Dropbox/The politics of interruptions - JOP RR/Replication Files/Table")

stargazer(model_20.1.1b,model_20.1.2b,model_20.1.3,model_20.1.4,
          model_0.1.1b,model_0.1.2b,model_0.1.3,model_0.1.4,
          model_50.1.1b,model_50.1.2b,model_50.1.3,model_50.1.4,
          model_100.1.1b,model_100.1.2b,model_100.1.3,model_100.1.4,
          model_200.1.1b,model_200.1.2b,model_200.1.3,model_200.1.4,
          type = "html", style = "ajps", out = "tableB2.html",
          covariate.labels = c("Woman","Ideological Extremism","Committee Chair",
                               "Seniority", "National MC", "Same Party as Leg. Pres.", "New Constitution",
                               "Mean Negative Language (Session)",
                               "Election Year", "Negative Language (Speech)",
                               "Topic: Women"),
          omit = "factor",
          no.space=TRUE,
          dep.var.labels=c("Number of Speeches Original","Length of Speech Original","Number of Speeches No Threshold","Length of Speech No Threshold",
                           "Number of Speeches 50-word Threshold","Length of Speech 50-word Threshold","Number of Speeches 100-word Threshold","Length of Speech 100-word Threshold",
                           "Number of Speeches 200-word Threshold","Length of Speech 200-word Threshold"),
          digits=3,
          df = FALSE,
          keep.stat = c("theta", "n"))
